
Namespace _2bMatesSite.Controls
	Imports System
	Imports System.Data
	Imports System.Drawing
	Imports System.Web
	Imports System.Web.UI.WebControls
	Imports System.Web.UI.HtmlControls
	Imports _2bMatesSite.BO


	''' <summary>
	'''		Summary description for Member.
	''' </summary>
	Public Partial Class Member
		Inherits System.Web.UI.UserControl
		Protected nUserID As Integer = -1

		' 
'		 * Property Name: ID
'		 * Property Purpose: Set/Get Member's ID 
'		 


		Public Property UserID() As Integer
			Get
				Return nUserID
			End Get
			Set
				nUserID = value
			End Set
		End Property

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
			' Put user code to initialize the page here

			Dim usr As User = Users.GetUserByID(nUserID)

			If usr <> Nothing Then
				' set Age
				Dim lblAgeValue As New Label()
				lblAge.Font.Bold = True
				Dim age As TimeSpan = DateTime.Today - usr.BirthDay
				Dim ageYears As Double = (age.Days / 365)
				lblAge.Text = (Convert.ToInt32(ageYears)).ToString()
				lblAge.Visible = True

				' set Gender
				If (usr.Gender > Constants.GENDER_UNSPECIFIED) AndAlso (usr.Gender <= Constants.GENDER_FEMALE) Then
					lblSex.Text = String.Format(", {0}", Constants.ARR_GENDER(usr.Gender))
				End If

				'
'				if (usr.Gender == 1)
'				{
'					lblSex.Text = string.Format("{0}, ", Constants.ARR_GENDER[usr.Gender] ); //"Man";
'				}
'				else if (usr.Gender == 2)
'				{
'					lblSex.Text = "Female, "; //"Woman";
'				}
'					 else
'					{
'						lblSex.Visible = false;
'					}
'				

				' set City
				If (usr.City <> Nothing) AndAlso (usr.City <> "") Then
					lblCity.Text = ", " + HttpUtility.HtmlEncode(usr.City)
				End If

				' set Country
				If usr.CountryID = -1 Then
					lblCountry.Text = String.Empty
				Else
					lblCountry.Text = ", " + Constants.COUNTRIES.GetCountryByID(usr.CountryID).Name
				End If

				If usr.DefaultPicture <> Nothing Then
					imgMemberBoxImage.ImageUrl = Pictures.GetPictureSrcFullURL(usr.DefaultPicture, True, "../")
				Else
					imgMemberBoxImage.ImageUrl = Constants.DEFAULT_THUMBNAIL_IMAGE_URL
				End If
				'hlMemberPhoto.ToolTip = usr.Name;

				Dim curURL As String = Request.ServerVariables("URL")

				hlMemberPhoto.ToolTip = usr.Name
				imgMemberBoxImage.ToolTip = usr.Name
				hlMemberPhoto.NavigateUrl = "../" + Constants.MEMBERS + "?id=" + nUserID
				lblName.Text = usr.Name
				hlMemberURL.Text = usr.Name
				lblNameTitle.Text = usr.Name
				hlMemberURL.NavigateUrl = "../" + Constants.MEMBERS + "?id=" + nUserID
				hlMemberProfile.NavigateUrl = "../" + Constants.MEMBERS + "?id=" + nUserID
				If curURL.IndexOf("/" + Constants.VIEW_MEMBER_PHOTOS_PAGE) <> -1 Then
					hlMemberPhotoAlbum.Visible = False
					lblMemberPhotoAlbum.Visible = True
				Else
					hlMemberPhotoAlbum.NavigateUrl = "../" + Constants.VIEW_MEMBER_PHOTOS_PAGE + "?id=" + nUserID
					hlMemberPhotoAlbum.Visible = True
					lblMemberPhotoAlbum.Visible = False
				End If
				If curURL.IndexOf("/" + Constants.SEE_ALL_FRIENDS) <> -1 Then
					hlMemberFriends.Visible = False
					lblMemberFriends.Visible = True
				Else
					hlMemberFriends.NavigateUrl = "../" + Constants.SEE_ALL_FRIENDS + "?id=" + nUserID
					hlMemberFriends.Visible = True
					lblMemberFriends.Visible = False
				End If
				If curURL.IndexOf("/" + Constants.VIEW_MEMBER_BLOG) <> -1 Then
					hlMemberBlog.Visible = False
					lblMemberBlog.Visible = True
				Else
					hlMemberBlog.NavigateUrl = "../" + Constants.VIEW_MEMBER_BLOG + "?id=" + nUserID
					hlMemberBlog.Visible = True
					lblMemberBlog.Visible = False
				End If
				hlAddToFriends.NavigateUrl = "../" + Constants.ADD_FRIEND_CONFIRMATION_PAGE + "?id=" + nUserID + "&action=" + Constants.NEW_FRIENDSHIP
				hlAddToFavourites.NavigateUrl = "../" + Constants.ADD_TO_FAVORITES + "?id=" + nUserID
				hlForwardToFriend.NavigateUrl = "../" + Constants.SEND_MESSAGE + "?" + Constants.FORWARD_A_FRIEND_PARAM + "=" + nUserID + "&action=" + Constants.MESSAGE_FORWARD_A_FRIEND_ACTION
				hlSendMessage.NavigateUrl = "../" + Constants.SEND_MESSAGE + "?uid=" + nUserID

				hlBlockUser.NavigateUrl = "../" + Constants.BLOCK_USER + "?id=" + nUserID
			End If
		End Sub

		#region Web Form Designer generated code
		Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		'''		Required method for Designer support - do not modify
		'''		the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()

		End Sub
#End Region
	End Class
End Namespace






